/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.suspend.floatwindow;

import android.content.Context;
import android.os.RemoteException;
import android.text.TextUtils;
import com.qihoo.gamecenter.sdk.suspend.b.e.g;
import com.qihoo.gamecenter.sdk.suspend.e.c;
import com.qihoo.gamecenter.sdk.suspend.floatwindow.floattingicon.c.a;
import com.qihoo.gamecenter.sdk.suspend.remote.QRemoteService;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

public class a {
    public static int a = 1;
    private ScheduledExecutorService d;
    private com.qihoo.gamecenter.sdk.suspend.floatwindow.floattingicon.b e;
    private Context f;
    c b = null;
    com.qihoo.gamecenter.sdk.suspend.b.b.a.b c = new com.qihoo.gamecenter.sdk.suspend.b.b.a.b() {
        public void a(String paramString1, String paramString2, int paramInt) {
            if ((paramInt == 0) && (!(TextUtils.isEmpty(paramString1))))
                return;
            a.this.a(paramString2, a.a(a.this));
        }
    };

    public void a(Context paramContext, com.qihoo.gamecenter.sdk.suspend.remote.a parama,
            com.qihoo.gamecenter.sdk.suspend.floatwindow.floattingicon.b paramb) {
        if ((paramContext == null) || (parama == null) || (TextUtils.isEmpty(parama.b())) || (paramb == null))
            return;
        this.e = paramb;
        this.f = paramContext;
        try {
            a(parama, QRemoteService.a().b(parama.b()), paramContext);
        } catch (RemoteException localRemoteException) {
            localRemoteException.printStackTrace();
        }
    }

    public void a(com.qihoo.gamecenter.sdk.suspend.remote.a parama, String paramString, Context paramContext) {
        if (g.a(paramContext)) {
            if (this.b == null) {
                this.b = new c(paramContext, new com.qihoo.gamecenter.sdk.suspend.e.a(parama, paramContext) {
                    public void a(int paramInt, String paramString1, ArrayList paramArrayList, String paramString2) {
                        if (TextUtils.isEmpty(this.b.b())) {
                            com.qihoo.gamecenter.sdk.suspend.b.b.a("FloatInitConf", "getCurrRunAppName returned null.");
                            return;
                        }
                        if (paramInt != 0)
                            a.this.a(null, this.b, this.c);
                        else
                            a.this.a(paramArrayList, this.b, this.c);
                    }
                });
            }
            else if (this.b.b()) {
                this.b.a(true);
                this.b = new c(paramContext, new com.qihoo.gamecenter.sdk.suspend.e.a(parama, paramContext) {
                    public void a(int paramInt, String paramString1, ArrayList paramArrayList, String paramString2) {
                        if (TextUtils.isEmpty(this.b.b())) {
                            com.qihoo.gamecenter.sdk.suspend.b.b.a("FloatInitConf", "getCurrRunAppName returned null.");
                            return;
                        }
                        if (paramInt != 0)
                            a.this.a(null, this.b, this.c);
                        else
                            a.this.a(paramArrayList, this.b, this.c);
                    }
                });
            }
            this.b.a(parama.b(), paramString);
        }
        else {
            com.qihoo.gamecenter.sdk.suspend.remote.b.b().b(parama);
        }
    }

    public void a(ArrayList paramArrayList, com.qihoo.gamecenter.sdk.suspend.remote.a parama, Context paramContext) {
        if ((this.e == null) || (paramArrayList == null) || (paramArrayList.size() < 1) || (parama == null)
                || (TextUtils.isEmpty(parama.b()))) {
            com.qihoo.gamecenter.sdk.suspend.remote.b.b().b(parama);
            return;
        }
        ArrayList localArrayList1 = new ArrayList();
        ArrayList localArrayList2 = new ArrayList();
        ArrayList localArrayList3 = new ArrayList();
        c.a locala = null;
        com.qihoo.gamecenter.sdk.suspend.e.b localb = null;
        int i = paramArrayList.size();
        boolean bool1 = com.qihoo.gamecenter.sdk.suspend.c.a.b(paramContext);
        boolean bool2 = true;
        for (int j = 0; j < i; ++j) {
            localb = (com.qihoo.gamecenter.sdk.suspend.e.b) paramArrayList.get(j);
            localb.g(parama.b());
            if ("float_setting".equals(localb.e()))
                continue;
            locala = new c.a();
            locala.a = localb.b();
            com.qihoo.gamecenter.sdk.suspend.remote.b.b().a(localb.a());
            localArrayList3.add(localb);
            if ((TextUtils.isEmpty(com.qihoo.gamecenter.sdk.suspend.a.a.a.a().b(localb.d())))
                    && (!(TextUtils.isEmpty(localb.d()))))
                localArrayList1.add(localb.d());
            bool2 = com.qihoo.gamecenter.sdk.suspend.c.a.c(paramContext, localb.e());
            if ((bool1) && (((!(bool1)) || (!(bool2)))))
                continue;
            locala.c = localb.c();
            locala.e = localb;
            locala.d = localb.g();
            if ((TextUtils.isEmpty(com.qihoo.gamecenter.sdk.suspend.a.a.a.a().b(localb.c())))
                    && (!(TextUtils.isEmpty(localb.c()))))
                a(localb.c(), paramContext);
            localArrayList2.add(locala);
            com.qihoo.gamecenter.sdk.suspend.b.a.a("360FloatSdk_show_" + localb.e(), localb.f(), this.f);
        }
        com.qihoo.gamecenter.sdk.suspend.remote.b.b().a(localArrayList3);
        if (this.e != null)
            this.e.a(localArrayList2, parama);
        if (localArrayList1.size() <= 0)
            return;
        a(localArrayList1);
    }

    public void a(String paramString, Context paramContext) {
        if (this.d == null)
            this.d = Executors.newScheduledThreadPool(2);
        this.d.submit(new com.qihoo.gamecenter.sdk.suspend.b.b.a.a(paramContext, paramString, this.c));
    }

    public void a(ArrayList paramArrayList) {
        int i = paramArrayList.size();
        for (int j = 0; j < i; ++j) {
            if (TextUtils.isEmpty((CharSequence) paramArrayList.get(j)))
                continue;
            a((String) paramArrayList.get(j), this.f);
        }
    }
}